package com.yc.thread.pro3_bestMatching;

import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @author zwei
 * @create 2024-07-25 10:24
 */
public class TestMain {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        String path=System.getProperty("user.home")+"//word.txt";
        System.out.println(path);
        List<String>list=WorldsLoader.load(path);
        System.out.println(list.size());
        String word="d";
        BestMatchingTask task=new BestMatchingTask(list,word,0,list.size());
        FutureTask<BestMatchingData>futureTask=new FutureTask<>(task);
        Thread thread=new Thread(futureTask);
        thread.start();

        BestMatchingData bestMatchingData=futureTask.get(); //阻塞式方法  只有任务运行完了才会得到结果，程序继续向下
        System.out.println(bestMatchingData.getDistance()+"\n"+bestMatchingData.getWords());

    }
}
